<template>
  <div class="dashboard-editor-container">
    <panel-group @handleSetLineChartData="handleSetLineChartData" />
    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <el-tabs v-model="casCadeName" type="card" @tab-click="handleClick">
            <el-tab-pane
              v-for="item in cascadeList"
              :key="item.id"
              :label="item.name"
              :name="item.id"
            >
              {{ item.name }}
              <pie-chartJl
                :key="currentCascade"
                :type="Number(currentCascade)"
              />
            </el-tab-pane>
          </el-tabs>
          <div class="echarts-title">级联人员结构</div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <el-tabs
            v-model="activeName"
            type="card"
            @tab-click="handleOtherClick"
          >
            <el-tab-pane
              v-for="item in cascadeList"
              :key="item.id"
              :label="item.name"
              :name="item.id"
            >
              {{ item.name }}
              <pie-chartGql
                v-if="currentActiveName === item.id"
                :key="currentActiveName"
                :type="Number(currentActiveName)"
              />
            </el-tab-pane>
          </el-tabs>
          <div class="echarts-title">供取料人员结构</div>
        </div>
      </el-col>
    </el-row>

    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <BarChart :type="1" />
          <div class="echarts-title">中核兰铀</div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <BarChart :type="2" />
          <div class="echarts-title">中核陕铀</div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <BarChart :type="3" />
          <div class="echarts-title">四川红华</div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import PanelGroup from "./dashboard/PanelGroup";
import LineChart from "./dashboard/LineChart";
import RaddarChart from "./dashboard/RaddarChart";
import PieChartJl from "./dashboard/PieChartJl";
import PieChartGql from "./dashboard/PieChartGql";
import BarChart from "./dashboard/BarChart";

const lineChartData = {};

export default {
  name: "Index",
  components: {
    PanelGroup,
    LineChart,
    RaddarChart,
    PieChartJl,
    PieChartGql,
    BarChart,
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis,
      casCadeName: "1",
      currentCascade: "1",
      cascadeList: [
        {
          id: "1",
          name: "性别",
        },
        {
          id: "2",
          name: "年龄",
        },
        {
          id: "3",
          name: "学历",
        },
        {
          id: "4",
          name: "工龄",
        },
      ],
      activeName: "1",
      currentActiveName: "1",
    };
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type];
    },

    handleClick(e) {
      this.currentCascade = e.name;
    },
    handleOtherClick(e) {
      this.currentActiveName = e.name;
    },
  },
};
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .chart-wrapper1 {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
    width: 50%;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;

    .echarts-title {
      padding-bottom: 24px;
      text-align: center;
    }
  }

  ::v-deep .el-tabs__header {
    border-bottom: none;
  }

  ::v-deep .el-tabs__item {
    padding: 0 10px;
    height: 24px;
    line-height: 24px;
    border-bottom: 1px solid #dfe4ed;
    font-size: 12px;
  }

  ::v-deep .el-tabs__item.is-active {
    border-bottom: 1px solid #1890ff;
    border-color: 1px solid #1890ff;
    background-color: #1890ff;
    color: #fff;
  }

  ::v-deep.el-tabs--top.el-tabs--card > .el-tabs__header .el-tabs__item {
    padding: 0 10px;
  }
}

@media (max-width: 1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
